#pragma once

#include <QObject>

#include <QOpenGLWidget>
#include <osgGA/NodeTrackerManipulator>
#include <osgGA/OrbitManipulator>
#include <osgViewer/CompositeViewer>

#include <osgEarth/MapNode>

class sceneWidget : public QOpenGLWidget {
public:
	sceneWidget(QWidget* parent = 0);
	virtual ~sceneWidget();
	virtual osgViewer::CompositeViewer* getViewer()
	{
		return _viewer;
	}
	void addView(osg::GraphicsContext* graphicsWindow);
	void frame();
protected:
	virtual void paintGL();

	virtual void resizeGL(int width, int height);

	virtual void initializeGL();

	virtual void mouseMoveEvent(QMouseEvent* event);

	virtual void mousePressEvent(QMouseEvent* event);

	virtual void mouseReleaseEvent(QMouseEvent* event);

	virtual void wheelEvent(QWheelEvent* event);

	virtual bool event(QEvent* event);

private:

	osgGA::EventQueue* getEventQueue() const {
		osgGA::EventQueue* eventQueue = _graphicsWindow->getEventQueue();
		return eventQueue;
	}

	std::string _appDirPath;
	std::string _dataDirPath;

	/*osg::ref_ptr<osgViewer::CompositeViewer> _viewer;*/
	osg::ref_ptr<osgViewer::CompositeViewer> _viewer;
	osg::observer_ptr<osgViewer::View> _view;
	osg::ref_ptr<osg::Node> _earthFileNode;
	osg::ref_ptr<osgEarth::MapNode> _mapNode;
	osg::ref_ptr<osg::Group> _rootNode;

	QRectF _geometry;
	osg::ref_ptr<osgViewer::GraphicsWindow> _graphicsWindow;
	qreal m_scale;
};
